package com.site.dao;

import com.site.common.DbHelper;
import com.site.entity.HeaderEntity;
import com.site.entity.NewTypeEntity;

import javax.swing.text.html.parser.Entity;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class HeaderDao extends DbHelper {
    public HeaderDao() throws ClassNotFoundException, SQLException{

    }

    //得到所有导航标题和数据绑定
    public List<HeaderEntity> getAll() throws SQLException {
        ResultSet rs= query("select * from tbheader");
        List<HeaderEntity> list=new ArrayList<HeaderEntity>();
        while (rs.next()){
            list.add(getEntity(rs));
        }

        rs.close();
        close();
        return list;
    }

    private HeaderEntity getEntity(ResultSet rs) throws SQLException {
        HeaderEntity entity=new HeaderEntity();
        entity.setTitle(rs.getString("title"));
        entity.setSource(rs.getString("source"));
        return entity;
    }
}
